{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "nbsphinx": "hidden"
   },
   "source": [
    "# The Laplace Transform\n",
    "\n",
    "*This Jupyter notebook is part of a [collection of notebooks](../index.ipynb) in the bachelors module Signals and Systems, Communications Engineering, Universität Rostock. Please direct questions and suggestions to [Sascha.Spors@uni-rostock.de](mailto:Sascha.Spors@uni-rostock.de).*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Properties\n",
    "\n",
    "The Laplace transform has a number of specific properties which can be concluded directly from its definition. The most important ones in the context of signals and systems are reviewed in the following."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Linearity\n",
    "\n",
    "The Laplace transform is a linear operation, as can be concluded straightforwardly from its definition, . For two signals $x_1(t)$ and $x_2(t)$ with Laplace transforms $X_1(s) = \\mathcal{L} \\{ x_1(t) \\}$ and $X_2(s) = \\mathcal{L} \\{ x_2(t) \\}$ the following holds\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\{ A \\cdot x_1(t) + B \\cdot x_2(t) \\} = A \\cdot X_1(s) + B \\cdot X_2(s)\n",
    "\\end{equation}\n",
    "\n",
    "with $A, B \\in \\mathbb{C}$. The region of convergence (ROC) of the superposition $A x_1(t) + B x_2(t)$ is as least as large as the intersection of the ROCs of $x_1(t)$ and $x_2(t)$\n",
    "\n",
    "\\begin{equation}\n",
    "\\text{ROC} \\{ A \\cdot x_1(t) + B \\cdot x_2(t) \\} \\supseteq \\text{ROC} \\{ x_1(t) \\} \\cap \\text{ROC} \\{ x_2(t) \\}\n",
    "\\end{equation}\n",
    "\n",
    "The Laplace transform of a weighted superposition of signals is equal to the weighted superposition of the individual Laplace transforms. This property is useful to derive the Laplace transform of signals that can be expressed as superposition of other signals for which the Laplace transforms are known or can be calculated easier."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Transformation of the cosine and sine signal\n",
    "\n",
    "The Laplace transform of the causal cosine $\\epsilon(t) \\cdot \\cos(\\omega_0 t)$ and sine $\\epsilon(t) \\cdot \\sin(\\omega_0 t)$ signal is derived by expressing the cosine/sine as harmonic exponential signals using [Euler's formula](https://en.wikipedia.org/wiki/Euler's_formula)\n",
    "\n",
    "\\begin{align}\n",
    "\\cos(\\omega_0 t) &= \\frac{1}{2} \\left( e^{j \\omega_0 t} + e^{-j \\omega_0 t} \\right) \\\\\n",
    "\\sin(\\omega_0 t) &= \\frac{1}{2j} \\left( e^{j \\omega_0 t} - e^{-j \\omega_0 t} \\right)\n",
    "\\end{align}\n",
    "\n",
    "The Laplace transform of the [causal complex exponential signal](definition.ipynb#Transformation-of-the-Causal-Complex-Exponential-Signal) reads\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\{ \\epsilon(t) \\cdot e^{-s_0 t} \\} = \\frac{1}{s + s_0} \\qquad \\text{for } \\Re \\{ s \\} > \\Re \\{ - s_0 \\}\n",
    "\\end{equation}\n",
    "\n",
    "Using the linearity of the Laplace transform yields\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\{ \\epsilon(t) \\cdot \\cos(\\omega_0 t) \\} = \n",
    "\\frac{1}{2} \\left( \\frac{1}{s - j \\omega_0} + \\frac{1}{s + j \\omega_0} \\right) = \\frac{s}{s^2 + \\omega_0^2}\n",
    "\\qquad \\text{for } \\Re \\{ s \\} > 0\n",
    "\\end{equation}\n",
    "\n",
    "and\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\{ \\epsilon(t) \\cdot \\sin(\\omega_0 t) \\} = \n",
    "\\frac{1}{2j} \\left( \\frac{1}{s - j \\omega_0} - \\frac{1}{s + j \\omega_0} \\right) = \\frac{\\omega_0}{s^2 + \\omega_0^2}\n",
    "\\qquad \\text{for } \\Re \\{ s \\} > 0\n",
    "\\end{equation}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Example - Computational transformation of the cosine signal**\n",
    "\n",
    "The Laplace transform of the causal cosine signal is calculated in `Sympy`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAASsAAAAyBAMAAAD2JOBgAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAq0Rmid0iMu92ELuZVM0av29pAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFvUlEQVRYCc1ZXWgcVRT+9n8zu8mupKL44hIVBKHZF0VUzGaJ4CI0KxL/aGEE9cEIG0GbFyGpFKvW4ioFTTF2HqIoERMpGlSkW7Bai9ZFLFRRs+BbsVB/SGmpjefcmblz78xIfkrGHNiZc777zZxv5t6598wsQBYr0WaT2KwlhfRK7/93MqddDbGK622G/UlXxM2usyn2+aItI31uU8iRIu6zvVRFIpvCOWUJGbduCjGeiJ6W8Hd7iO1x5z425kcji+NLnKrrgi9hd5uARtOHRhj+zrlSfHNUy3OQbCdrFRWN0F+0KNmEv7v6gHkkzBpuilCKmmqOe+pqFWG/iUwLSexBwfQ3RRPn6pRnlz9XC11tPJpeQrbtb4omTtCYz/zlz7WAiZZxOnMBqbK/KZrYIElJ8Tiq+e4e3PfHsTLJynIfr8vMsKNUMM0EFeBYGnVgblJGjjN7yXzjRVAnFtbdiVX/OSmmkeFZnK84jCUoHwHZeY+seSsO+aE3Te0ADp48scC7sIQ/cIO0afICrGTtS0EYBuZakqo7NWzVAV/U0zbu90FIFzFcIjCQEDA6GrnHCmGdwdsmswZKmODbGWbJ2vEwWGJUDt0jA8eJWchOkh8iK1/WyIlWkJWoIyn6jjQttjX66oMPATEdq0dkLyDGj1CIrKzKI/+lICtXRLdYCakHB8Z8/NWGF4F+/yXF6ohx9abLEo+df0T85mcBhRbi/3D6QhEHTXbWbgbLKgePS50lrIrE1JAVf3B6mxnf0jtdJ+gL+hXp55Ymg0FZdJPiYhYtzGP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+T4y2Z67K+HsmzXJ4Ts/uQ/reryBOt+PVIMjfM+VWe+ZD0Vvp6JIkb5nh/3CFXcrOs9PXI5W3c/gOLz/0vZ+WGiZdJDDEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\left ( \\frac{\\omega_{0}}{\\omega_{0}^{2} + s^{2}}, \\quad 0, \\quad 2 \\left|{\\arg{\\left (\\omega_{0} \\right )}}\\right| = 0\\right )$$"
      ],
      "text/plain": [
       "⎛   ω₀                       ⎞\n",
       "⎜────────, 0, 2⋅│arg(ω₀)│ = 0⎟\n",
       "⎜  2    2                    ⎟\n",
       "⎝ω₀  + s                     ⎠"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import sympy as sym\n",
    "sym.init_printing()\n",
    "\n",
    "t, w0 = sym.symbols('t omega0', real=True)\n",
    "s = sym.symbols('s', complex=True)\n",
    "\n",
    "x = sym.sin(w0*t)\n",
    "X, a, cond = sym.laplace_transform(x, t, s)\n",
    "X, a, cond"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise**\n",
    "\n",
    "* Determine the zeros and poles of the Laplace transform $\\mathcal{L} \\{ \\epsilon(t) \\cdot \\sin(\\omega_0 t) \\}$ by manual calculus and by extending above example. What specific symmetries do the zeros and poles show in the $s$-plane?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Symmetry for Real-Valued Signals\n",
    "\n",
    "The Laplace transform of the complex conjugate $x^*(t)$ of a signal $x(t)$ is given as\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\{ x^*(t) \\} = \\int_{-\\infty}^{\\infty} x^*(t) \\, e^{-s t} dt \n",
    "= \\left( \\int_{-\\infty}^{\\infty} x(t) \\, e^{-s^* t} dt \\right)^* \n",
    "= X^*(s^*)\n",
    "\\end{equation}\n",
    "\n",
    "where $X(s) = \\mathcal{L} \\{ x(t) \\}$. The ROC for $x^*(t)$ is equal to the ROC for $x(t)$. Above result is used to derive the Laplace transform of the real part of the signal $x(t)$\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\left\\{ \\Re \\{ x(t) \\} \\right\\} = \\mathcal{L} \\left\\{ \\frac{1}{2} [ x(t) + x^*(t) ] \\right\\} = \\frac{1}{2} \\left[ X(s) + X^*(s^*) \\right]\n",
    "\\end{equation}\n",
    "\n",
    "and imaginary part\n",
    "\n",
    "\\begin{equation}\n",
    "\\mathcal{L} \\left\\{ \\Im \\{ x(t) \\} \\right\\} = \\mathcal{L} \\left\\{ \\frac{1}{2j} [ x(t) - x^*(t) ] \\right\\} = \\frac{1}{2j} \\left[ X(s) - X^*(s^*) \\right]\n",
    "\\end{equation}\n",
    "\n",
    "For a real-valued signal $x(t) \\in \\mathbb{R}$ with $\\Im \\{ x(t) \\} = 0$ it follows that\n",
    "\n",
    "\\begin{equation}\n",
    "X(s) = X^*(s^*)\n",
    "\\end{equation}\n",
    "\n",
    "It can be concluded, that the Laplace transform of a real valued signal shows complex conjugate symmetry. The real/imaginary part of the Laplace transform show even/odd symmetry\n",
    "\n",
    "\\begin{align}\n",
    "\\Re \\{ X(s) \\} &= \\Re \\{ X(-s) \\} \\\\\n",
    "\\Im \\{ X(s) \\} &= - \\Im \\{ X(-s) \\}\n",
    "\\end{align}\n",
    "\n",
    "respectively and accordingly its magnitude/phase show also even/odd symmetry\n",
    "\n",
    "\\begin{align}\n",
    "|X(s)| &= |X(-s)| \\\\\n",
    "\\varphi(s) &= - \\varphi(-s)\n",
    "\\end{align}\n",
    "\n",
    "where $\\varphi(s) = \\arg \\{ H(s) \\}$.\n",
    "\n",
    "The poles and zeros of a [Laplace transform which can be expressed as a rational function](definition.ipynb#Representation) in $s$ \n",
    "\n",
    "\\begin{equation}\n",
    "X(s) = \\frac{\\sum_{m=0}^{M} \\beta_m s^m}{\\sum_{n=0}^{N} \\alpha_n s^n} = K \\cdot \\frac{\\prod_{\\mu=0}^{Q} (s - s_{0 \\mu})}{\\prod_{\\nu=0}^{P} (s - s_{\\infty \\nu})}\n",
    "\\end{equation}\n",
    "\n",
    "with $Q=M-1$ and $P=N-1$ show also specific symmetries. From the specific symmetry $X(s) = X^*(s^*)$ of the Laplace transform of a real-valued signal $x(t) \\in \\mathbb{R}$, it can be concluded that the coefficients $\\alpha_n, \\beta_m$ of the numerator and denominator are real-valued. The [complex conjugate root theorem](https://en.wikipedia.org/wiki/Complex_conjugate_root_theorem) states that the roots of a polynomial with real valued coefficients are either real-valued or complex conjugate pairs. Hence, the zeros and poles of the Laplace transform $X(s)$ of a real-valued signal $x(t)$ are either real-valued or constitute complex conjugate pairs."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "nbsphinx": "hidden"
   },
   "source": [
    "**Copyright**\n",
    "\n",
    "This notebook is provided as [Open Educational Resource](https://en.wikipedia.org/wiki/Open_educational_resources). Feel free to use the notebook for your own purposes. The text is licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/), the code of the IPython examples under the [MIT license](https://opensource.org/licenses/MIT). Please attribute the work as follows: *Sascha Spors, Continuous- and Discrete-Time Signals and Systems - Theory and Computational Examples*."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
